package com.trkj.service;


import com.trkj.dao.EmpDao;
import com.trkj.entity.DepartmentTransfer;
import com.trkj.entity.Dept;
import com.trkj.entity.Employee;
import com.trkj.entity.EmployeeMovement;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Data
@Service
public class EmpServiceImpl implements EmpService{
    @Resource
    private EmpDao employeeDao;
    @Override
    @Transactional
    public int addEmployee(Employee emp) {
        int count= employeeDao.addEmployee(emp);
        log.debug("完成插入{}",emp);
        return count;
    }
    @Transactional
    public int updateEmployee(Employee emp){
        int count= employeeDao.updateEmployee(emp);
        log.debug("完成修改{}",emp);
        return count;
    }

    @Transactional
    public int addEmployeeMovement(EmployeeMovement emp) {
        int count= employeeDao.addEmployeeMovement(emp);
        log.debug("完成插入{}",emp);
        return count;
    }
    @Override
    @Transactional
    public int addDept(DepartmentTransfer dept){
        int count=employeeDao.addDepartmentTransfer(dept);
        log.debug("完成插入{}",dept);
        return count;
    }
    @Transactional
    public int updateEmployee2(Employee emp){
        int count= employeeDao.updateEmployee2(emp);
        log.debug("完成插入{}",emp);
        return count;
    }
    public List<Map<String,Object>> selectYG(int id){
        List<Map<String,Object>> list= employeeDao.selectYG(id);
        log.debug("完成插入{}",id);
        return list;
    }
    public List<Map<String,Object>> countYG(){
        List<Map<String,Object>> list= employeeDao.countEmployeesByYear();
        log.debug("完成查询{}");
        return list;
    }
    public List<Map<String,Object>> countYGR(){
        List<Map<String,Object>> list= employeeDao.countEmployeesByDepartment();
        log.debug("完成查询{}");
        return list;
    }
    public  int insertDept(Dept dept){
        int count= employeeDao.insertDept(dept);
        log.debug("完成插入{}",dept);
        return count;
    }
    public int deleteYG(int id){
        int count=employeeDao.deleteYG(id);
        log.debug("完成删除");
        return count;
    }
    public int updateGz(){
        int count=employeeDao.updateEmployee3();
        log.debug("完成修改");
        return count;
    }

}
